
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>docker13 容器数据卷 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="docker14 具名挂载和匿名挂载.html" />
    
    
    <link rel="prev" href="docker12 commit镜像.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="docker01 docker能干嘛.html">
            
                <a href="docker01 docker能干嘛.html">
            
                    
                    docker01 docker能干嘛
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="docker02 安装docker.html">
            
                <a href="docker02 安装docker.html">
            
                    
                    docker02 安装docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="docker03 docker原理.html">
            
                <a href="docker03 docker原理.html">
            
                    
                    docker03 docker原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="docker04 镜像基本命令.html">
            
                <a href="docker04 镜像基本命令.html">
            
                    
                    docker04 镜像基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="docker05 容器基本命令.html">
            
                <a href="docker05 容器基本命令.html">
            
                    
                    docker05 容器基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="docker06 常用其他命令.html">
            
                <a href="docker06 常用其他命令.html">
            
                    
                    docker06 常用其他命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="docker07 进入当前正在运行的容器.html">
            
                <a href="docker07 进入当前正在运行的容器.html">
            
                    
                    docker07 进入当前正在运行的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="docker08 部署nginx.html">
            
                <a href="docker08 部署nginx.html">
            
                    
                    docker08 部署nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="docker09 部署tomcat.html">
            
                <a href="docker09 部署tomcat.html">
            
                    
                    docker09 部署tomcat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="docker10 可视化面板.html">
            
                <a href="docker10 可视化面板.html">
            
                    
                    docker10 可视化面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="docker11 镜像原理.html">
            
                <a href="docker11 镜像原理.html">
            
                    
                    docker11 镜像原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="docker12 commit镜像.html">
            
                <a href="docker12 commit镜像.html">
            
                    
                    docker12 commit镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.14" data-path="docker13 容器数据卷.html">
            
                <a href="docker13 容器数据卷.html">
            
                    
                    docker13 容器数据卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="docker14 具名挂载和匿名挂载.html">
            
                <a href="docker14 具名挂载和匿名挂载.html">
            
                    
                    docker14 具名挂载和匿名挂载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="docker15 初始dockerfile.html">
            
                <a href="docker15 初始dockerfile.html">
            
                    
                    docker15 初始dockerfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="docker16 数据卷容器.html">
            
                <a href="docker16 数据卷容器.html">
            
                    
                    docker16 数据卷容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="docker17 dockerFile.html">
            
                <a href="docker17 dockerFile.html">
            
                    
                    docker17 dockerFile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="docker18 dockerFile基本命令.html">
            
                <a href="docker18 dockerFile基本命令.html">
            
                    
                    docker18 dockerFile基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="docker19 构建自己的centos.html">
            
                <a href="docker19 构建自己的centos.html">
            
                    
                    docker19 构建自己的centos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="docker20 发布镜像.html">
            
                <a href="docker20 发布镜像.html">
            
                    
                    docker20 发布镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="docker21 网络详情.html">
            
                <a href="docker21 网络详情.html">
            
                    
                    docker21 网络详情
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="docker22 容器互联.html">
            
                <a href="docker22 容器互联.html">
            
                    
                    docker22 容器互联
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="docker23 自定义网络.html">
            
                <a href="docker23 自定义网络.html">
            
                    
                    docker23 自定义网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                <a href="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                    
                    docker24 SpringBoot 微服务打包Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="docker25 dockerFile_demo.html">
            
                <a href="docker25 dockerFile_demo.html">
            
                    
                    docker25 dockerFile_demo
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >docker13 容器数据卷</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x5BB9;&#x5668;&#x6570;&#x636E;&#x5377;">&#x5BB9;&#x5668;&#x6570;&#x636E;&#x5377;</h3>
<p>&#x4EC0;&#x4E48;&#x662F;&#x5BB9;&#x5668;&#x6570;&#x636E;&#x5377;</p>
<p>docker &#x7684;&#x7406;&#x5FF5;&#x56DE;&#x987E;</p>
<p>&#x5C06;&#x5E94;&#x7528;&#x548C;&#x73AF;&#x5883;&#x6253;&#x5305;&#x6210;&#x4E00;&#x4E2A;&#x955C;&#x50CF;</p>
<p>&#x6570;&#x636E;?&#x5982;&#x679C;&#x6570;&#x636E;&#x90FD;&#x5728;&#x5BB9;&#x5668;&#x4E2D;,&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x5BB9;&#x5668;&#x5220;&#x9664;,&#x6570;&#x636E;&#x90FD;&#x4F1A;&#x4E22;&#x5931;===&#x9700;&#x6C42;===:&#x6570;&#x636E;&#x53EF;&#x4EE5;&#x6301;&#x4E45;&#x5316;</p>
<p>MySQL,&#x5BB9;&#x5668;&#x5220;&#x4E86;,MySQL&#x91CC;&#x9762;&#x7684;&#x6570;&#x636E;&#x4F1A;&#x8DDF;&#x7740;&#x4E00;&#x5757;&#x513F;&#x4E22;,&#x8FD9;&#x4E2A;&#x5220;&#x5E93;&#x8DD1;&#x8DEF;&#x7684;&#x98CE;&#x9669;&#x5C31;&#x975E;&#x5E38;&#x5927;</p>
<p>&#x9700;&#x6C42;: MySQL&#x6570;&#x636E;&#x53EF;&#x4EE5;&#x5B58;&#x50A8;&#x5728;&#x672C;&#x5730;!</p>
<p>&#x5BB9;&#x5668;&#x4E4B;&#x95F4;&#x53EF;&#x4EE5;&#x6709;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5171;&#x4EAB;&#x7684;&#x6280;&#x672F;! Docker &#x5BB9;&#x5668;&#x4E2D;&#x4EA7;&#x751F;&#x7684;&#x6570;&#x636E;,&#x540C;&#x6B65;&#x5230;&#x672C;&#x5730;!</p>
<p>&#x8FD9;&#x5C31;&#x662F;&#x54B1;&#x4EEC;&#x7684;&#x5377;&#x6280;&#x672F;!!!</p>
<p>&#x8BF4;&#x767D;&#x4E86;&#x5C31;&#x662F;&#x76EE;&#x5F55;&#x7684;&#x6302;&#x8F7D;,&#x5C06;&#x6211;&#x4EEC;&#x5BB9;&#x5668;&#x5185;&#x7684;&#x76EE;&#x5F55;,&#x6302;&#x8F7D;&#x5230;Linux&#x4E0A;&#x9762;!</p>
<p>&#x540C;&#x6B65;&#x673A;&#x5236;</p>
<p><strong>&#x603B;&#x7ED3;&#x4E00;&#x53E5;&#x8BDD;:&#x5BB9;&#x5668;&#x7684;&#x6301;&#x4E45;&#x5316;&#x548C;&#x540C;&#x6B65;&#x64CD;&#x4F5C;! &#x5BB9;&#x5668;&#x95F4;&#x4E5F;&#x662F;&#x53EF;&#x4EE5;&#x6570;&#x636E;&#x5171;&#x4EAB;&#x7684;!</strong></p>
<h3 id="&#x4F7F;&#x7528;&#x6570;&#x636E;&#x5377;">&#x4F7F;&#x7528;&#x6570;&#x636E;&#x5377;</h3>
<blockquote>
<p>&#x65B9;&#x5F0F;&#x4E00;:&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x547D;&#x4EE4;&#x6765;&#x6302;&#x8F7D; -v</p>
</blockquote>
<ul>
<li>docker run -it -v &#x4E3B;&#x673A;&#x76EE;&#x5F55;:&#x5BB9;&#x5668;&#x5185;&#x76EE;&#x5F55;  # -v  &#x8BBE;&#x7F6E;&#x6620;&#x5C04;&#x76EE;&#x5F55;</li>
</ul>
<pre><code class="lang-bash">[root@izijy66dzll7bdz home]<span class="hljs-comment"># docker run -it -v /home/ceshi:/home centos /bin/bash</span>
[root@6b9426bbee28 /]<span class="hljs-comment">#</span>
</code></pre>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210323143400.png" alt=""></p>
<p>&#x5BB9;&#x5668;&#x5185;&#x521B;&#x5EFA;&#x4E2A;&#x6587;&#x4EF6;,&#x5916;&#x9762;&#x8FD8;&#x771F;&#x6709;</p>
<pre><code class="lang-bash">[root@izijy66dzll7bdz home]<span class="hljs-comment"># cd ceshi/</span>
[root@izijy66dzll7bdz ceshi]<span class="hljs-comment"># ls</span>
test.java
</code></pre>
<p><strong>&#x597D;&#x5904;,&#x6211;&#x4EEC;&#x4EE5;&#x540E;&#x4FEE;&#x6539;&#x53EA;&#x9700;&#x8981;&#x5728;&#x672C;&#x5730;&#x4FEE;&#x6539;&#x5373;&#x53EF;,&#x5BB9;&#x5668;&#x5185;&#x90E8;&#x4F1A;&#x81EA;&#x52A8;&#x540C;&#x6B65;</strong></p>
<h4 id="&#x5B9E;&#x6218;&#x5B89;&#x88C5;mysql">&#x5B9E;&#x6218;&#x5B89;&#x88C5;MySQL</h4>
<p><strong>&#x601D;&#x8003;:MySQL&#x7684;&#x6570;&#x636E;&#x6301;&#x4E45;&#x5316;&#x95EE;&#x9898;?</strong></p>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x83B7;&#x53D6;&#x955C;&#x50CF;</span>

<span class="hljs-comment"># &#x8FD0;&#x884C;&#x5BB9;&#x5668;,&#x9700;&#x8981;&#x505A;&#x6570;&#x636E;&#x6302;&#x8F7D;!</span>
<span class="hljs-comment"># &#x5B89;&#x88C5;&#x542F;&#x52A8;mysql,&#x9700;&#x8981;&#x914D;&#x7F6E;&#x5BC6;&#x7801;&#x7684;,&#x8FD9;&#x662F;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x95EE;&#x9898;</span>
<span class="hljs-comment"># &#x5B98;&#x65B9;&#x7684;&#x6D4B;&#x8BD5;</span>
<span class="hljs-comment"># &#x542F;&#x52A8;&#x6211;&#x4EEC;&#x7684;</span>
<span class="hljs-_">-d</span> &#x540E;&#x53F0;&#x8FD0;&#x884C;
-p &#x7AEF;&#x53E3;&#x6620;&#x5C04;
-v &#x5377;&#x6302;&#x8F7D;
<span class="hljs-_">-e</span> &#x73AF;&#x5883;&#x914D;&#x7F6E;
--name &#x5BB9;&#x5668;&#x540D;&#x5B57;

<span class="hljs-comment">#&#x8FD9;&#x662F;&#x5B98;&#x65B9;&#x7684;&#x6D4B;&#x8BD5;</span>
docker run --name some-mysql <span class="hljs-_">-e</span> MYSQL_ROOT_PASSWORD=123456 <span class="hljs-_">-d</span> mysql:tag

<span class="hljs-comment"># &#x8FD0;&#x884C;mysql</span>
docker run  <span class="hljs-_">-d</span>  -p 3310:3306  -v /home/mysql/conf:/etc/mysql/conf.d  -v /home/mysql/data:/var/lib/mysql  --name mysql01  <span class="hljs-_">-e</span> MYSQL_ROOT_PASSWORD=123456 mysql:8.0
</code></pre>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x8FDB;&#x5165;&#x5230;mysql&#x4E2D;</span>
[root@izijy66dzll7bdz data]<span class="hljs-comment">#  docker exec -it  b720fca37722 /bin/bash</span>
root@b720fca37722:/<span class="hljs-comment"># ls</span>
bin   dev                         entrypoint.sh  home  lib64  mnt  proc  run   srv  tmp  var
boot  docker-entrypoint-initdb.d  etc            lib   media  opt  root  sbin  sys  usr
root@b720fca37722:/<span class="hljs-comment">#</span>
</code></pre>
<p>&#x542F;&#x52A8;&#x6210;&#x529F;&#x4E4B;&#x540E;,&#x6211;&#x4EEC;&#x5728;&#x672C;&#x5730;&#x4F7F;&#x7528; idea&#x6765;&#x8FDE;&#x63A5;&#x6D4B;&#x8BD5;&#x4E00;&#x4E0B;</p>
<p>idea&#x8FDE;&#x63A5;&#x5230;&#x670D;&#x52A1;&#x5668;&#x7684;3310-&gt; docker &#x5185;&#x7684; 3306&#x6620;&#x5C04;,&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x8FDE;&#x63A5;&#x4E0A;&#x4E86;</p>
<p>&#x5728;&#x672C;&#x5730;&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x5E93;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5E93;,&#x67E5;&#x770B;&#x6211;&#x4EEC;&#x6620;&#x5C04;&#x7684;&#x8DEF;&#x5F84;&#x662F;&#x5426;ok!</p>
<p>&#x5047;&#x8BBE;&#x6211;&#x4EEC;&#x5C06;&#x5BB9;&#x5668;&#x5220;&#x9664;</p>
<p>&#x53D1;&#x73B0;,&#x6211;&#x4EEC;&#x6302;&#x8F7D;&#x5230;&#x672C;&#x5730;&#x7684;&#x6570;&#x636E;&#x5377;&#x4F9D;&#x65E7;&#x6CA1;&#x6709;&#x4E22;&#x5931;,&#x8FD9;&#x5C31;&#x662F;&#x5B9E;&#x73B0;&#x4E86;&#x5BB9;&#x5668;&#x6570;&#x636E;&#x7684;&#x6301;&#x4E45;&#x5316;&#x529F;&#x80FD;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="docker12 commit镜像.html" class="navigation navigation-prev " aria-label="Previous page: docker12 commit镜像">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="docker14 具名挂载和匿名挂载.html" class="navigation navigation-next " aria-label="Next page: docker14 具名挂载和匿名挂载">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"docker13 容器数据卷","level":"1.14","depth":1,"next":{"title":"docker14 具名挂载和匿名挂载","level":"1.15","depth":1,"path":"docker14 具名挂载和匿名挂载.md","ref":"docker14 具名挂载和匿名挂载.md","articles":[]},"previous":{"title":"docker12 commit镜像","level":"1.13","depth":1,"path":"docker12 commit镜像.md","ref":"docker12 commit镜像.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docker13 容器数据卷.md","mtime":"2021-04-17T06:21:12.859Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T07:50:48.567Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

